package com.hsyt.pfc.core.autoconfigure;

import com.hsyt.pfc.core.annotation.EnableWaitingQueue;
import com.hsyt.pfc.core.queue.WaitingQueueManager;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description:
 * @ClassName: WaitingQueueAutoConfigure
 * @Package: com.hsyt.pfc.core.autoconfigure
 * @Author: wangze@hsyuntai.com
 * @Date: 2018年10月8日 9:36
 * @Copyright: 版权归 HSYUNTAI 所有
 */
@Configuration
@ConditionalOnBean(annotation = EnableWaitingQueue.class)
public class WaitingQueueAutoConfigure {

    @Bean(initMethod = "initQueue")
    @ConditionalOnMissingBean(value = WaitingQueueManager.class)
    @ConfigurationProperties(prefix = "waitingqueue")
    public WaitingQueueManager waitingQueueManager() {
        WaitingQueueManager manager = new WaitingQueueManager();
        return manager;
    }
}
